package com.newtouch.avmarketing.mgr.modules.avmarkrting.api;

import com.newtouch.avmarketing.mgr.modules.avmarkrting.model.Result;
import com.newtouch.avmarketing.mgr.modules.avmarkrting.model.ResultCodes;
import com.newtouch.avmarketing.mgr.modules.avmarkrting.service.SoundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.File;

@Api(value = "音频播放API", tags = "07 双录节点：音频播放API")
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/api/sound")
public class SoundApi {

    @Autowired
    private SoundService soundService;

    @ApiOperation("音频播放")
    @PostMapping("/playSound")
    public Result playSound(@RequestParam("file") File file){
        try {
        soundService.playSound(file);
        return Result.of(ResultCodes.SUCCESS_CODE,"播放成功! ");
        }catch (Exception e){
            log.error("错误信息：",e);
        }
        return Result.of(ResultCodes.ERROR_CODE,"播放失败");
    }
}
